import {
  reqAddressInfo,
  reqOrderInfo
} from '../../api'
const state = {
  address: [],
  orderInfo:{}
}
const mutations = {
  USERADDRESS(state, address) {
    state.address = address
  },
  ORDERINFO(state, orderInfo) {
    state.orderInfo = orderInfo
  }

}
const actions = {
  //获取用户地址信息
  async getUserAddress({
    commit
  }) {
    let result = await reqAddressInfo()
    if (result.code == 200) {
      commit('USERADDRESS', result.data)
    }
  },
  //获取商品清单
  async getOrderInfo({
    commit
  }) {
    let result =await reqOrderInfo()
    if (result.code == 200) {
      commit('ORDERINFO', result.data)
    }
  }
}
//相当于计算属性，简化数据
const getters = {

}
export default ({
  state,
  mutations,
  actions,
  getters
})